<template>
  <div class="app-container">
    <el-row>
      <el-col :span="24">
        <div class="h_top">
          <div class="bread_title">
            <span>提交点检计划</span>
          </div>
          <div class="save_button">
            <div class="buttonBox">
              <el-button type="primary" icon="el-icon-back" size="mini" @click="goBack">返回</el-button>
            </div>
            <div class="buttonBox">
              <el-button type="primary" icon="el-icon-document-checked" size="mini" @click="save">保存</el-button>
            </div>
          </div>
        </div>
      </el-col>
    </el-row>
    <div>
      <el-row>
        <el-col :span="24">
          <el-form ref="form" :model="data" :inline="true" :rules="formRules">
            <el-input v-model="data.category" type="hidden" />
            <el-row :gutter="10">
              <el-col :span="4">
                <el-form-item prop="coding">
                  <div>编号</div>
                  <el-input v-model="data.coding" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="name">
                  <div>名称</div>
                  <el-input v-model="data.name" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="type">
                  <div>类型</div>
                  <el-select v-model="data.type" size="mini">
                    <el-option v-for="(item, index) in groupType" :key="index" :value="index" :label="item" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="unit">
                  <div>单位</div>
                  <el-select v-model="data.unit" size="mini">
                    <el-option v-for="(item,index) in planType" :key="index" :label="item" :value="index" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="equipment_id">
                  <div>资产</div>
                  <v-select-s v-model="data.equipment_id" action="eqList" :query="{type:data.type,unit:data.unit,add_field: 'coding'}" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="priority">
                  <div>优先程度</div>
                  <el-select v-model="data.priority" size="mini">
                    <el-option v-for="(item,index) in priority" :key="index" :label="item" :value="index" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="profession">
                  <div>专业</div>
                  <el-select v-model="data.profession" size="mini">
                    <el-option v-for="(item,index) in profession" :key="index" :label="item" :value="index" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="period">
                  <div>周期</div>
                  <el-input v-model="data.period" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="cost_id">
                  <div>成本中心</div>
                  <v-select v-model="data.cost_id" action="costList" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="admin_id">
                  <div>负责人</div>
                  <v-select-s v-model="data.admin_id" action="adminList" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="execute_date">
                  <div>执行时间</div>
                  <el-date-picker v-model="data.execute_date" type="datetime" placeholder="选择日期时间" align="right" value-format="yyyy-MM-dd HH:mm:ss" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="status">
                  <div>状态</div>
                  <el-select v-model="data.status" size="mini">
                    <el-option v-for="(item,index) in commonStatus" :key="index" :label="item" :value="index" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item>
                  <div>下一个日期</div>
                  <el-date-picker v-model="data.next_date" type="date" disabled size="mini" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="ready">
                  <div>准备（天数）</div>
                  <el-input v-model="data.ready" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="sort">
                  <div>排序</div>
                  <el-input v-model="data.sort" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="task_long">
                  <div>任务时长（小时）</div>
                  <el-input v-model="data.task_long" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="workshop">
                  <div>车间</div>
                  <el-select v-model="data.workshop" size="mini">
                    <el-option v-for="(item,index) in planWorkshop" :key="index" :label="item" :value="index" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="4" hidden>
                <el-form-item prop="is_send">
                  <div>是否发送给负责人</div>
                  <el-select v-model="data.is_send" size="mini">
                    <el-option v-for="(item,index) in planSend" :key="index" :label="item" :value="index" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="4" hidden>
                <el-form-item prop="bz_check">
                  <div>是否班长审核</div>
                  <el-select v-model="data.bz_check" size="mini">
                    <el-option v-for="(item,index) in planSend" :key="index" :label="item" :value="index" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="4" hidden>
                <el-form-item prop="engineer_check">
                  <div>是否工程师审核</div>
                  <el-select v-model="data.engineer_check" size="mini">
                    <el-option v-for="(item,index) in planSend" :key="index" :label="item" :value="index" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item>
                  <div>计划类别</div>
                  <el-select v-model="data.category" size="mini" disabled>
                    <el-option v-for="(item,index) in planCategory" :key="index" :label="item" :value="index" />
                  </el-select>
                </el-form-item>
              </el-col>
              <!--                        <el-col :span="8">-->
              <!--                            <div>该维护计划周末是否释放工单</div>-->
              <!--                            <el-form-item>-->
              <!--                                <el-checkbox-->
              <!--                                        label="星期六"-->
              <!--                                        v-model="data.is_provider"-->
              <!--                                        :true-label="1"-->
              <!--                                        :false-label="0"-->
              <!--                                ></el-checkbox>-->
              <!--                                <el-checkbox-->
              <!--                                        label="星期天"-->
              <!--                                        v-model="data.is_manufacturer"-->
              <!--                                        :true-label="1"-->
              <!--                                        :false-label="0"-->
              <!--                                ></el-checkbox>-->
              <!--                                <el-checkbox-->
              <!--                                        label="法定节假日"-->
              <!--                                        v-model="data.is_epiboly"-->
              <!--                                        :true-label="1"-->
              <!--                                        :false-label="0"-->
              <!--                                ></el-checkbox>-->
              <!--                            </el-form-item>-->
              <!--                        </el-col>-->
            </el-row>
          </el-form>
          <el-tabs>
            <el-tab-pane label="描述">
              <el-row :gutter="10">
                <el-col :span="24">
                  <Tinymce id="content" v-model="data.content" />
                </el-col>
              </el-row>
            </el-tab-pane>
          </el-tabs>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import API from '@/api/project/plan'
import Tinymce from '@/components/Tinymce/index'
import VSelect from '@/components/select'
import VSelectS from '@/components/select-search'
import { profession, priority, commonStatus, planType, groupType, planSend, planCategory, planWorkshop } from '@/utils/options'
export default {
  inject: ['addOne', 'goUrl'],
  components: {
    Tinymce,
    VSelect,
    VSelectS
  },
  data() {
    return {
      data: {
        coding: '',
        name: '',
        unit: '',
        execute_date: '',
        period: '',
        ready: '',
        is_send: 0,
        bz_check: 0,
        engineer_check: 0,
        category: 0,
        sort: 100
      },
      profession,
      priority,
      commonStatus,
      groupType,
      planType,
      planSend,
      planCategory,
      planWorkshop,
      formRules: {
        coding: [
          {
            required: true,
            message: '请输入编号',
            trigger: 'blur'
          }
        ],
        name: [
          {
            required: true,
            message: '请输入名称',
            trigger: 'blur'
          }
        ],
        unit: [
          {
            required: true,
            message: '请输入单位',
            trigger: 'change'
          }
        ],
        equipment_id: [
          {
            required: true,
            message: '请选择资产',
            trigger: 'change'
          }
        ],
        priority: [
          {
            required: true,
            message: '请选择优先程度',
            trigger: 'change'
          }
        ],
        profession: [
          {
            required: true,
            message: '请选择专业',
            trigger: 'change'
          }
        ],
        execute_date: [
          {
            required: true,
            message: '请输入执行时间',
            trigger: 'blur'
          }
        ],
        period: [
          {
            required: true,
            message: '请输入周期',
            trigger: 'blur'
          }
        ],
        cost_id: [
          {
            required: true,
            message: '请选择成本中心',
            trigger: 'change'
          }
        ],
        admin_id: [
          {
            required: true,
            message: '请选择维护负责人',
            trigger: 'change'
          }
        ],
        type: [
          {
            required: true,
            message: '请选择类型',
            trigger: 'change'
          }
        ],
        status: [
          {
            required: true,
            message: '请选择状态',
            trigger: 'change'
          }
        ],
        ready: [
          {
            required: true,
            message: '请填写准备（天数）',
            trigger: 'blur'
          }
        ],
        task_long: [
          {
            required: true,
            message: '请输入任务时长',
            trigger: 'blur'
          }
        ],
        workshop: [
          {
            required: true,
            message: '请选择车间',
            trigger: 'change'
          }
        ],
        sort: [
          {
            required: true,
            message: '请输入排序',
            trigger: 'blur'
          }
        ]
      }
    }
  },
  created() {},
  methods: {
    save() {
      const thisData = this.data
      const thisForm = this.$refs.form
      this.addOne(API, thisData, thisForm)
    },
    goBack() {
      this.goUrl('/project/plan1')
    }
  }
}
</script>

<style>
.table tr th {
  text-align: right;
}
</style>
